package com.xiaoshuidi.cloud.module.report.constant;


import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

@Getter
@AllArgsConstructor
public enum EvictionTypeEnum {

    NORMAL_RENTING("1", "正常退租"),
    BREACH_RENTING("2", "违约退租"),
    CONSULT_RENTING("3","协商退租"),
    CHANGING_ROOMS("4","中途换房"),
    RENEWAL_ROOMS("5","续租换房"),
    ;

    private String code;
    private String msg;

    private static final Map<String, EvictionTypeEnum> enumMap = new HashMap<>();

    static {
        EvictionTypeEnum[] values = EvictionTypeEnum.values();
        for (EvictionTypeEnum value : values) {
            enumMap.put(value.getCode(), value);
        }
    }

    public static EvictionTypeEnum getEnum(String num) {
        return enumMap.get(num);
    }

    public static String getEnumByCode(String code) {
        EvictionTypeEnum[] evictionTypeEnums = values();
        for (EvictionTypeEnum evictionTypeEnum : evictionTypeEnums) {
            if (evictionTypeEnum.code.equals(code)) {
                return evictionTypeEnum.code;
            }
        }
        return null;
    }
}
